package com.tpi.smartpayments;

/**
 * <p>Title: SmartPaymentsClient_JavaHTTPPost</p>
 *
 * <p>Description: A simple example to show how to use HTTP POST to send
 * transactions to the SmartPayments Web Service</p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: TPI Software</p>
 *
 * @author Andy Chau
 * @version 1.0
 */
public class TrxDetail extends Base {
    public TrxDetail() {
        url = "https://www.tpisoft.com/Admin/ws/TrxDetail.asmx";
    }
    public TrxDetail(String url) {
        this.url = url;
    }

    synchronized public String GetCardTrx(
            String	UserName,			// required
            String	Password,			// required
            String	RPNum,				// required: the merchant key to query against, may or may not be the same as the username account
            String	PNRef,				// optional: if provided, all other filters below will be ignored
            String	BeginDt,			// optional:
            String	EndDt,				// optional:
            String	PaymentType,			// optional: IN clause e.g. 'PAYRECEIPT', 'ECHECK','VISA', etc.
            String	ExcludePaymentType,		// optional: IN clause
            String	TransType,			// optional: IN clause  e.g. 'Authorization', 'Capture','Credit', etc.
            String	ExcludeTransType,		// optional: IN clause
            String	ApprovalCode,			// optional: LIKE clause
            String	Result,				// optional: 0 mean approved, anything else is declined
            String	ExcludeResult,			// optional:
            String	NameOnCard,			// optional: LIKE clause
            String	CardNum,			// optional: LIKE clause
            String	CardType,			// optional: IN clause
            String	ExcludeCardType,		// optional: IN clause
            String	ExcludeVoid,			// optional: True or False, default is true
            String	User,				// optional: LIKE clause
            String	invoiceId,			// optional: LIKE clause
            String	SettleFlag,			// optional: either NULL, '0' or '1'
            String      SettleMsg,			// optional:
            String	SettleDt,			// optional:
            String	TransformType,			// optional: Either "XML", "XSL", or "DELIM"
            String	Xsl,				// optional: the XSL for transforming the XML data
            String	ColDelim,			// optional: column delimiter character, only applied if the Xsl field is empty
            String	RowDelim,			// optional: row delimiter character, only applied if the Xsl field is empty
            String	IncludeHeader,			// optional: whether to include header in the DELIM output
            String	ExtData
            ) throws java.io.IOException {
        java.lang.StringBuffer sb = new StringBuffer();
        sb.append("UserName=" + urlEncode(UserName));
        sb.append("&Password=" + urlEncode(Password));
        sb.append("&RPNum=" + urlEncode(RPNum));
        sb.append("&PNRef=" + urlEncode(PNRef));
        sb.append("&BeginDt=" + urlEncode(BeginDt));
        sb.append("&EndDt=" + urlEncode(EndDt));
        sb.append("&PaymentType=" + urlEncode(PaymentType));
        sb.append("&ExcludePaymentType=" + urlEncode(ExcludePaymentType));
        sb.append("&TransType=" + urlEncode(TransType));
        sb.append("&ExcludeTransType=" + urlEncode(ExcludeTransType));
        sb.append("&ApprovalCode=" + urlEncode(ApprovalCode));
        sb.append("&Result=" + urlEncode(Result));
        sb.append("&ExcludeResult=" + urlEncode(ExcludeResult));
        sb.append("&NameOnCard=" + urlEncode(NameOnCard));
        sb.append("&CardNum=" + urlEncode(CardNum));
        sb.append("&CardType=" + urlEncode(CardType));
        sb.append("&ExcludeCardType=" + urlEncode(ExcludeCardType));
        sb.append("&ExcludeVoid=" + urlEncode(ExcludeVoid));
        sb.append("&User=" + urlEncode(User));
        sb.append("&invoiceId=" + urlEncode(invoiceId));
        sb.append("&SettleFlag=" + urlEncode(SettleFlag));
        sb.append("&SettleMsg=" + urlEncode(SettleMsg));
        sb.append("&SettleDt=" + urlEncode(SettleDt));
        sb.append("&TransformType=" + urlEncode(TransformType));
        sb.append("&Xsl=" + urlEncode(Xsl));
        sb.append("&ColDelim=" + urlEncode(ColDelim));
        sb.append("&RowDelim=" + urlEncode(RowDelim));
        sb.append("&IncludeHeader=" + urlEncode(IncludeHeader));
        sb.append("&ExtData=" + urlEncode(ExtData));
        String postData = sb.toString();
        String responseData = Util.sendHttpPost(url + "/GetCardTrx", postData, timeout, verbose);
        responseData = responseData.replaceAll("&lt;", "<");
        responseData = responseData.replaceAll("&gt;", ">");
       return responseData;
    }


    public String GetCardTrxSummary(
            String	UserName,				// required
            String	Password,				// required
            String	RPNum,					// required: the merchant key to query against, may or may not be the same as the username account
            String	BeginDt,				// optional:
            String	EndDt,					// optional:
            String	ApprovalCode,			// optional: LIKE clause
            String	Register,				// optional:
            String	NameOnCard,				// optional: LIKE clause
            String	CardNum,				// optional: LIKE clause
            String	CardType,				// optional: IN clause
            String	ExcludeVoid,			// optional: True or False, default is true
            String	User,					// optional: LIKE clause
            String	SettleFlag,				// optional: either NULL, '0' or '1'
            String  SettleMsg,				// optional:
            String	SettleDt,				// optional: True/False or 1/0
            String	TransformType,			// optional: Either "XML", "XSL", or "DELIM"
            String	Xsl,					// optional: the XSL for transforming the XML data
            String	ColDelim,				// optional: column delimiter character, only applied if the Xsl field is empty
            String	RowDelim,				// optional: row delimiter character, only applied if the Xsl field is empty
            String	IncludeHeader,			// optional: whether to include header in the DELIM output
            String	ExtData
            ) throws java.io.IOException {
        java.lang.StringBuffer sb = new StringBuffer();
        sb.append("UserName=" + urlEncode(UserName));
        sb.append("&Password=" + urlEncode(Password));
        sb.append("&RPNum=" + urlEncode(RPNum));
        sb.append("&BeginDt=" + urlEncode(BeginDt));
        sb.append("&EndDt=" + urlEncode(EndDt));
        sb.append("&ApprovalCode=" + urlEncode(ApprovalCode));
        sb.append("&Register=" + urlEncode(Register));
        sb.append("&NameOnCard=" + urlEncode(NameOnCard));
        sb.append("&CardNum=" + urlEncode(CardNum));
        sb.append("&CardType=" + urlEncode(CardType));
        sb.append("&ExcludeVoid=" + urlEncode(ExcludeVoid));
        sb.append("&User=" + urlEncode(User));
        sb.append("&SettleFlag=" + urlEncode(SettleFlag));
        sb.append("&SettleMsg=" + urlEncode(SettleMsg));
        sb.append("&SettleDt=" + urlEncode(SettleDt));
        sb.append("&TransformType=" + urlEncode(TransformType));
        sb.append("&Xsl=" + urlEncode(Xsl));
        sb.append("&ColDelim=" + urlEncode(ColDelim));
        sb.append("&RowDelim=" + urlEncode(RowDelim));
        sb.append("&IncludeHeader=" + urlEncode(IncludeHeader));
        sb.append("&ExtData=" + urlEncode(ExtData));
        String postData = sb.toString();
        String responseData = Util.sendHttpPost(url + "/GetCardTrxSummary", postData, timeout, verbose);
        responseData = responseData.replaceAll("&lt;", "<");
        responseData = responseData.replaceAll("&gt;", ">");
       return responseData;
    }



    synchronized public String GetCheckTrx(
            String	UserName,			// required
            String	Password,			// required
            String	RPNum,				// required: the merchant key to query against, may or may not be the same as the username account
            String	PNRef,				// optional: if provided, all other filters below will be ignored
            String	BeginDt,			// optional:
            String	EndDt,				// optional:
            String	PaymentType,			// optional: IN clause e.g. 'PAYRECEIPT', 'ECHECK','VISA', etc.
            String	ExcludePaymentType,		// optional: IN clause
            String	TransType,			// optional: IN clause  e.g. 'Authorization', 'Capture','Credit', etc.
            String	ExcludeTransType,		// optional: IN clause
            String	ApprovalCode,			// optional: LIKE clause
            String	Result,				// optional: 0 mean approved, anything else is declined
            String	ExcludeResult,			// optional:
            String	NameOnCheck,			// optional: LIKE clause
            String	CheckNum,			// optional: LIKE clause
            String	AcctNum,			// optional: LIKE clause
            String	RouteNum,			// optional: LIKE clause
            String	ExcludeVoid,			// optional: True or False, default is true
            String	User,				// optional: LIKE clause
            String	invoiceId,			// optional: LIKE clause
            String	SettleFlag,			// optional: either NULL, '0' or '1'
            String      SettleMsg,			// optional:
            String	SettleDt,			// optional:
            String	TransformType,			// optional: Either "XML", "XSL", or "DELIM"
            String	Xsl,				// optional: the XSL for transforming the XML data
            String	ColDelim,			// optional: column delimiter character, only applied if the Xsl field is empty
            String	RowDelim,			// optional: row delimiter character, only applied if the Xsl field is empty
            String	IncludeHeader,			// optional: whether to include header in the DELIM output
            String      ExtData                         // optional: Extended Data in XML, Valid Values are: IMAGE_TYPE - can be NO_IMAGE, ONLY_IMAGE or ALL. CustomerID, Amount, RegisterNum
            ) throws java.io.IOException {

       java.lang.StringBuffer sb = new StringBuffer();
       sb.append("UserName=" + urlEncode(UserName));
       sb.append("&Password=" + urlEncode(Password));
       sb.append("&RPNum=" + urlEncode(RPNum));
       sb.append("&PNRef=" + urlEncode(PNRef));
       sb.append("&BeginDt=" + urlEncode(BeginDt));
       sb.append("&EndDt=" + urlEncode(EndDt));
       sb.append("&PaymentType=" + urlEncode(PaymentType));
       sb.append("&ExcludePaymentType=" + urlEncode(ExcludePaymentType));
       sb.append("&TransType=" + urlEncode(TransType));
       sb.append("&ExcludeTransType=" + urlEncode(ExcludeTransType));
       sb.append("&ApprovalCode=" + urlEncode(ApprovalCode));
       sb.append("&Result=" + urlEncode(Result));
       sb.append("&ExcludeResult=" + urlEncode(ExcludeResult));
       sb.append("&NameOnCheck=" + urlEncode(NameOnCheck));
       sb.append("&CheckNum=" + urlEncode(CheckNum));
       sb.append("&AcctNum=" + urlEncode(AcctNum));
       sb.append("&RouteNum=" + urlEncode(RouteNum));
       sb.append("&ExcludeVoid=" + urlEncode(ExcludeVoid));
       sb.append("&User=" + urlEncode(User));
       sb.append("&invoiceId=" + urlEncode(invoiceId));
       sb.append("&SettleFlag=" + urlEncode(SettleFlag));
       sb.append("&SettleMsg=" + urlEncode(SettleMsg));
       sb.append("&SettleDt=" + urlEncode(SettleDt));
       sb.append("&TransformType=" + urlEncode(TransformType));
       sb.append("&Xsl=" + urlEncode(Xsl));
       sb.append("&ColDelim=" + urlEncode(ColDelim));
       sb.append("&RowDelim=" + urlEncode(RowDelim));
       sb.append("&IncludeHeader=" + urlEncode(IncludeHeader));
       sb.append("&ExtData=" + urlEncode(ExtData));
       String postData = sb.toString();
       String responseData = Util.sendHttpPost(url + "/GetCheckTrx", postData, timeout, verbose);
       responseData = responseData.replaceAll("&lt;", "<");
       responseData = responseData.replaceAll("&gt;", ">");
      return responseData;
   }

   public String GetOpenBatchSummary(
           String username, // Required: The merchants username
           String password, // Required: The merchants password
           String rpNum, // Required: The merchants user_key
           String beginDt, // Optional: The beginning date of the range in mm/dd/yyyy format
           String endDt, // Optional: The ending date of the range in mm/dd/yyyy format
           String extData // Optional: XML data
          )throws java.io.IOException {

      java.lang.StringBuffer sb = new StringBuffer();
      sb.append("username=" + urlEncode(username));
      sb.append("&password=" + urlEncode(password));
      sb.append("&rpNum=" + urlEncode(rpNum));
      sb.append("&beginDt=" + urlEncode(beginDt));
      sb.append("&endDt=" + urlEncode(endDt));
      sb.append("&extData=" + urlEncode(extData));
      String postData = sb.toString();
      String responseData = Util.sendHttpPost(url + "/GetOpenBatchSummary", postData, timeout, verbose);
      responseData = responseData.replaceAll("&lt;", "<");
      responseData = responseData.replaceAll("&gt;", ">");
     return responseData;
  }
}
